<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<head>
	<sx:head cache="false" />
	<link rel="stylesheet" href="/hrs-intranet/styles/displaytag.css" type="text/css" />
	<link rel="stylesheet" href="/hrs-intranet/styles/errortag.css" type="text/css" />
	<script type="text/javascript" src="/hrs-intranet/custom/js/calendarFix.js"></script>
	<script type="text/javascript" src="/hrs-intranet/custom/js/validateDays.js"></script>
</head>
<div class="left">

<s:if test="hasFieldErrors()">
	<div class="oldErrorMsg">
		<h4 class="oldErrorTitle">Error(s) with submission:</h4>
		<s:iterator value="fieldErrors">
			<s:iterator value="value">
				<li>
					<font class="errorMsgFont">
						<s:property/>
					</font>
				</li>
			</s:iterator>
		</s:iterator>
	</div>
	<br/>
	<br/>
</s:if>

<s:if test="(confirm || approved)">
	<h2>Change Time Off Status</h2>
</s:if>
<s:elseif test="(edited)">
	<h2>Edit Time Off</h2>
</s:elseif>
<s:elseif test="(actionMethod == 'TimeOffAction_save')">
	<h2>Create Time Off</h2>
</s:elseif>
<s:elseif test="(actionMethod == 'TimeOffAction_form')">
	<h2>View Time Off</h2>
</s:elseif>

<s:form validate="true" cssClass="formClass">
 <s:hidden key="requestId"/>
 <s:hidden key="actionMethod" value="%{actionMethod}"/>

 <s:hidden key="created"/>
 <s:hidden key="approved"/>
 <s:hidden key="confirm"/>
 <s:hidden key="edited"/>
 <s:hidden key="timeOffApproved"/>
 <s:hidden key="ownTimeOff"/>
 
  <s:hidden key="exceedExams" id="exceedExams"/>
  <s:hidden key="exceedComp" id="exceedComp"/>
  <s:hidden key="notWeekVacation" id="notWeekVacation"/>
  <s:hidden key="cancelledDays" id="cancelledDays"/>
  
  <s:param name="hasCreateOwnTimeOffPermission" value="%{hasCreateOwnTimeOffPermission()}" />
	
    <sx:autocompleter
        list="employeeList"
        listValue="person.name"
        value="%{selectedEmployeeName}"
        searchType="startword"
        listKey="id"
        showDownArrow="false"
        keyName="selectedEmployeeId"
        name="selectedEmployeeName"
        label="Employee"
        disabled="%{readOnly || approved  || edited || confirm || ownTimeOff}"
        required="true"
        autoComplete="false"
        forceValidOption="true"       
    />
	<sx:autocompleter 
		list="allTimeOffTypes" 
		listValue="name"
		keyName="name"
		key="selectedTimeOffType" 
		listKey="id"
		label="Time Off Type"
		showDownArrow="false"
		searchType="startword"
		disabled="%{readOnly || approved  || edited || confirm}"
		required="true"
        forceValidOption="true"
	/>
	<sx:datetimepicker key="selectedDateFrom" label="Date From" displayFormat="dd/MM/yyyy"  disabled="%{readOnly || approved}" required="true" displayFormat="dd/MM/yyyy" valueNotifyTopics="/value"/>
	<sx:datetimepicker key="selectedDateTo" label="Date To" displayFormat="dd/MM/yyyy"  disabled="%{readOnly || approved}" required="true" displayFormat="dd/MM/yyyy" valueNotifyTopics="/value"/>
	<sx:autocompleter
		list="possibleStatus"
		label="Status"
		showDownArrow="false"
		searchType="startword"
		name="selectedStatus"
		disabled="%{readOnly  || edited}"
		required="true"
		autoComplete="false"

	/>	
	
<!--	tipos NO aprobables ENFERMEDAD, NACIMIENTO, FALLECIMIENTO, ART-->
<s:if test="(created) && (selectedTimeOffType != 'ENFERMEDAD' && selectedTimeOffType != 'NACIMIENTO' && selectedTimeOffType != 'FALLECIMIENTO' && selectedTimeOffType != 'ART')"  >
	<sx:autocompleter
        list="employeeList"
        listValue="person.name"
        searchType="startword"
        listKey="id"
        showDownArrow="false"   
        keyName="selectedAssignedById" 
        name="selectedAssignedByName"
        label="To be approved by"
        required="true"
        autoComplete="false"
        forceValidOption="true"
        />	
</s:if>
<s:if test="(approved || readOnly || edited || confirm ) && (selectedTimeOffType != 'ENFERMEDAD' && selectedTimeOffType != 'NACIMIENTO' && selectedTimeOffType != 'FALLECIMIENTO' && selectedTimeOffType != 'ART')"  >
	<sx:autocompleter
        list="employeeList"
        listValue="person.name"
        searchType="startword"
        listKey="id"
        showDownArrow="false"   
        keyName="selectedAssignedById" 
        name="selectedAssignedByName"
        label="Approved/RejectedBy"
        disabled="%{readOnly || edited || confirm}"
        required="true"
        autoComplete="false"
        forceValidOption="true"
        />	
    </s:if>
	<s:textarea key="notes" label="Notes" disabled="%{readOnly}" rows="4" cols="16" cssClass="formTextAreaClass"/>

	<s:if test="certifiedTimeOff && ( confirm || (selectedStatus=='CANCELLED' || selectedStatus=='CONFIRMED') )">
		<s:radio list="certificates" name="certificatePresented"  disabled="%{readOnly || edited}"/>	
	</s:if>
	<s:if test="!readOnly">
		<s:submit action="%{actionMethod}" key="OK" disabled="%{readOnly}" cssClass="btn" cssStyle="position:relative; left:-95px;" id="okbutton"/>
		<s:url id="list_action" action="TimeOffAction_list" />
<!--		<s:a href="%{list_action}" cssClass="btnCancel" >Cancel</s:a>-->
		<s:submit action="%{actionMethod}" key="Cancel" cssClass="btnCancel" method="list" cssStyle="position:relative; left:0px; top:-25px; _top:-27" id="cancelbutton"/>
	</s:if>

</s:form>
</div>
<div class="right">
	<s:include value="timeoff_details_right_side.jsp"/>
</div>